//
//  Preferences.m
//  owa-notifier
//
//  Created by Sandeep Mistry on 13/07/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "Preferences.h"


@implementation Preferences

- (id)init
{
	self = [super init];
	
	NSMutableDictionary* defaultPrefs = [NSMutableDictionary dictionary];
	
	//[defaultPrefs setObject:[[NSString alloc] init] forKey:"@Host"];
	[defaultPrefs setObject:[NSNumber numberWithInt:5] forKey:@"PollInterval"];

	[[NSUserDefaults standardUserDefaults] registerDefaults:defaultPrefs];

	host = [[NSUserDefaults standardUserDefaults] stringForKey:@"Host"];
	pollInterval = [NSNumber numberWithInt:[[NSUserDefaults standardUserDefaults] integerForKey:@"PollInterval"]];
	
	return self;
}

- (void)dealloc
{
	//[prefs release];
	[super dealloc];
}

- (NSString*)host
{
	return host;
}

- (void)setHost:(NSString*)newHost
{
	[newHost retain];
	[host release];
	host = newHost;
	
	[[NSUserDefaults standardUserDefaults] setObject:host forKey:@"Host"];
}

- (NSNumber*)pollInterval
{
	return pollInterval;
}

- (void)setPollInterval:(NSNumber*)newPollInterval
{
	[newPollInterval retain];
	[pollInterval release];
	pollInterval = newPollInterval;
	
	[[NSUserDefaults standardUserDefaults] setObject:pollInterval forKey:@"PollInterval"];
}

@end
